<!-- 会员中心主内容区 -->
<div class="page-article">
  <div id="member_security" class="member-security">
     <div class="member_welhead"><ins></ins><b>
      <{if $verifyType == 'setmobile' || $verifyType == 'verifymobile'}><{t}>手机验证<{/t}><{else}><{t}>邮箱验证<{/t}><{/if}></b>
    </div>
	<div class='member-mod'>
    <!-- 步骤图 -->
	
 <!--   <div id="verify_steps" class="steps verify-steps">
	<div class="verify_li">
		<div class="step_item"><i class="iconfont">&#xe637;</i></div>
		<div class="verify_line"></div>
	</div>

	<div class="verify_li">
		<div class="step_item" style=" background-color:#1d93d0;"><i class="iconfont">&#xe64c;</i></div>
		<div class="verify_line"></div>
	</div>
	<div class="verify_li" style="width:300px">
		<div class="step_item"><i class="iconfont">&#xe628;</i></div>
		<div class="verify_line" style="width:180px;"></div>
		<div class="step_item"><i class="iconfont">&#xe633;</i></div>
	</div>

  
<div class="vrefy_forget">
	<div class="verify_text"><{t}>身份验证<{/t}></div>
	<div class="verify_text"><{t}>设置验证信息<{/t}></div>
	<div class="verify_text"><{t}>完成验证设置<{/t}></div>
</div>

    </div> -->
    <!-- 步骤图 -->


    <div id="verify_content" class="signupin-content verify-content">
      <form action="<{link app=b2c ctl=site_member act=verify_vcode2 arg0=$verifyType}>" method="post">
        <div class="verify_xx">
          <{if $verifyType == 'setmobile' || $verifyType == 'verifymobile'}>
          <{if $site_sms_valide == 'true'}>
			<div class="form-group">
            <label for=""><em class="warn">*</em><{t}>验证码：<{/t}></label>
     
              <{input type="vcode" name="forgotverifycode" class="sms-verify-input form-control" placeholder=$___b2c="填写验证码"|t:'b2c' data-caution=$___b2c="请正确填写验证码"|t:'b2c' key='LOGINVCODE' a_class="lnklike"}>
			</div>
     
          <{/if}>
			
			<{if $phones}>
			<div class="form-group">
			<label for="" ><{t}>手机号码：<{/t}></label>
				<select name="phone_setting" id="quhao" class="form-control">
					<{foreach from=$phones item=items}>
					<option sid="<{$items.length}>" value="<{$items.area}>"><{$items.country}><{$items.area}></option>
					<{/foreach}>
				</select>
			</div>
			<{/if}>
			

			<label for=""></label>
     
              <{if $verifyType == 'setmobile'}>
              <input type="hidden" name='send_type'  value="reset">
              <{input type="text" name="uname" id="" class="action-account-check form-control" vtype="required"}> <a href="<{link app=b2c ctl=site_passport act=send_vcode_sms}>" class="btn action-get-verifycode">
                <span><span><{t}>获取验证码<{/t}></span></span></a>
              <{/if}>
              <{if $verifyType == 'verifymobile'}>
                <{if $data.mobile}>
                  <{$data.mobile}>
                  <input type="hidden" name='send_type' value="activation">
                  <input type="hidden" name='uname' class="action-account-check" value=<{$data.mobile}> >
                <{else}>
                  <input type="hidden" name='send_type'  value="reset">
                  <{input type="text" name="uname" id="" class="action-account-check form-control" vtype="required"}>
                <{/if}>
                <a href="<{link app=b2c ctl=site_passport act=send_vcode_sms}>" class="btn btn-sm btn-primary pull-right action-get-verifycode" style="margin-top: 15px;"><span><span><{t}>获取验证码<{/t}></span></span></a>
				<div class="clearfix"></div>
              <{/if}>

  
          <{else}>
			<div class="form-group">
            <label for=""><{t}>邮箱：<{/t}></label>

              <{if $verifyType == 'setemail'}>
              <input type="hidden" name='send_type'  value="reset">
              <{input type="text" name="uname" id="" class="action-account-check" vtype="required&&email"}>
              <a href="<{link app=b2c ctl=site_passport act=send_vcode_email}>" class="btn btn-xs btn-default action-resend-email"><span><span><{t}>发送邮箱验证码<{/t}></span></span></a>
              <{/if}>
              <{if $verifyType == 'verifyemail'}>
                <{if $data.email}>
                  <input type="hidden" name='send_type'  value="reset">
                  <{input type="text" name="uname" id="" class="action-account-check" value=$data.email vtype="required&&email"}>
                <{else}>
                  <input type="hidden" name='send_type'  value="reset">
                  <{input type="text" name="uname" id="" class="action-account-check" vtype="required&&email"}>
                <{/if}>
                <a href="<{link app=b2c ctl=site_passport act=send_vcode_email}>" class="btn btn-xs btn-default action-resend-email"><span><span><{t}>发送邮箱验证码<{/t}></span></span></a>
              <{/if}>
			</div>
     
          <{/if}>
			<div class="form-group">
				<label for="" ><{t}>填写验证码：<{/t}></label>
			   <{input type="text" name="vcode" id="" vtype="required" class="form-control"}>
				<span class="caution-content"><{$msg}></span>
			</div>
			
          <label for=""></label>
		  <{button type="submit" rel="_request" class="btn btn-primary pull-right" label=$___b2c="提交"|t:'b2c'}>
		  <div class="clearfix"></div>
        </div>
      </form>
      <!--
      <div class="msg"><i class="icon icon-success">&#x25;</i> 恭喜您，您的手机已经验证完成，将会获取更好的安全体验</div>
      -->
    </div>
	</div>
  </div>
</div>
<script>
var module = $('verify_content');
var Query = {
    send: function(url, data, fn){
        new Request({
            url: url,
            link: 'cancel',
            onSuccess: function(rs) {
                try{
                    rs = JSON.decode(rs);
                }catch(e){}
                if(typeof rs.error === 'string') Message.error(rs.error);
                else if(typeof rs.success === 'string') Message.success(rs.success);
                fn && fn.call(this, rs);
            }
        }).post(data);
    }
};

function changeStep(rs, x, fn) {
    if(rs && rs[0]) {
        if(typeOf(rs[0]) === 'string') {
            module.innerHTML = rs[0];
            if(x) $('verify_steps').getElement('.active').removeClass('active').getSiblings('.step-' + x).addClass('active');
        }
        else if(typeOf(rs[0]) === 'object') {
            if(rs[0].error) return Message.error(rs[0].error);
        }
        fn && fn.call(this);
    }
}
module.addEvents({
    'change:relay(.action-verify-method)': function(e) {
        var form = this.getParent('form');
        form.getElements('.op-verify-mobile, .op-verify-email').addClass('hide');
        form.getElements('.op-verify-' + this.value).removeClass('hide');
    },
    'click:relay(.action-resend-email)':function(e) {
        e.stop();
        var url = this.href;
        var data = 'uname=' + module.getElement('.action-account-check').value + '&type=' + module.getElement('input[name=send_type]').value;
        Query.send(url, data);
    },
    'click:relay(.action-get-verifycode)': function(e) {
        e.stop();
        if(this.hasClass('disabled')) return false;
        var el = module.getElement('.action-account-check');
        if(this.hasClass('disabled')) return false;

		var obj = $$("#quhao option:selected");
		var phone_setting = '';
		if(obj && obj[0])
		{
			phone_setting = obj[0].value.replace("+","%2B");
		}

        <{if $site_sms_valide == 'true'}>
        var form = this.getParent('form');
        if(form.getElement('.sms-verify-input').value == '')
        {
          alert('<{t}>请输入验证码!<{/t}>');return;
        }
        sendVerify(this, 'uname=' + el.value + '&type=' + module.getElement('input[name=send_type]').value + '&phone_setting=' + phone_setting + '&sms_vcode=' + form.getElement('.sms-verify-input').value );
        <{else}>
        sendVerify(this, 'uname=' + el.value + '&phone_setting=' + phone_setting +'&type=' + module.getElement('input[name=send_type]').value);
        <{/if}>
    }
});

function sendVerify(el, data) {
    var url = el.href;
    el.addClass('disabled');
    var textCont = el.getElement('span span');
    textCont.innerHTML = el.get('text') + '(<i>0</i>)';
    var cd = new countdown(textCont.getElement('i'), {
        start: 120,
        secondOnly: true,
        callback: function(e) {
            el.removeClass('disabled');
            textCont.innerHTML = '<{t}>重发验证码<{/t}>';
        }
    });
    Query.send(url, data, function(rs){
        if(rs.error) {
          cd.stop();
          el.removeClass('disabled');
          textCont.innerHTML = '<{t}>重发验证码<{/t}>';
        }
    });
}
</script>
